package com.example.wendao.model.service;

import androidx.lifecycle.LiveData;
import androidx.paging.DataSource;


import com.example.wendao.model.db.dao.NewsPicsDao;
import com.example.wendao.model.db.database.AppDatabase;
import com.example.wendao.model.entity.NewsPics;

import java.util.List;


public class NewsPicsService {
    private NewsPicsDao newsPicsDao;
    public NewsPicsService(){ newsPicsDao= AppDatabase.getDatabases().getNewsPicsDao(); }

    //插入新闻图片
    /*
     * param:新闻图片
     * return:空
     * */
    public void insertNewsPic(NewsPics... newspics){ newsPicsDao.insertNewsPic(newspics);}

    //根据新闻id查询该新闻图片/*
    //    * param:新闻id
    //    * return:该新闻分页图片列表的数据源工厂
    //    * */
    public LiveData<List<NewsPics>> findNewsPicsByFatherId(int newspicfatherid){return newsPicsDao.findNewsPicsByFatherId(newspicfatherid);}

    //根据新闻id查找封面
    /*
     * param:新闻id
     * return:该新闻封面
     * */
    public NewsPics findCoverByFatherId(int newspicfatherid){
        return newsPicsDao.findCoverByFatherId(newspicfatherid);
    }

    //更新新闻配图
    /*
     * param:新闻图片
     * return:空
     * */
    public void updateNewsPics(NewsPics... newspics){ newsPicsDao.updateNewsPics(newspics);}

    //删除新闻配图
    /*
     * param:新闻图片
     * return:
     * */
    public void deleteNewsPics(NewsPics... newspics){newsPicsDao.deleteNewsPics(newspics);}




}
